// 引入Service和请求头ServiceName
import { Service, ServiceName } from '@/network/http.js'
import store from '@/store/index.js' // 引入store

const api = {
  /**
     * 获取堆存费
     * @param {Object} params 检索条件的obj
     */
  reqGetRulerCost(params) {
    return Service.get(
      `/${ServiceName}/api/external/costStorage/queryall`,
      { params }
    )
  },
  /**
     * 查看结算详情，用于获取下方结算数据
     * @param {Object} params {cargoInfoId,measureType,companyId,endTime}
     */
  reqGetSettlement(params) {
    return Service.get(
      `/${ServiceName}/api/external/costStorage/queryContractByCostInfo`, { params }
    )
  },
  /**
     * 根据结算明细ID查看结算详情
     * @param {String} statementId 结算明细ID
     */
  reqGetSettlementById(statementId) {
    return Service.get(
      `/${ServiceName}/api/external/costStorage/queryItemListById?statementId=${statementId}`
    )
  },
  /**
     * 查看结算
     * @param {Object} params {cargoInfoId,measureType}
     */
  reqGetSettlementDetail(params) {
    return Service.get(
      `/${ServiceName}/api/external/costStorage/queryCostListById`, { params }
    )
  },
  /**
     * 结算
     */
  reqSaveList(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/costStorage/addCost`,
      params
    )
  },
  /**
     * 审核
     * @param {String} id {id=航次id}
     */
  reqExamineList(id) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/costStorage/verifyByCostId?id=${id}`
    )
  },
  /**
     * 撤销结算
     * @param {String} id {id=航次id}
     */
  reqRevokeList(id) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/costStorage/cancleByCostId?id=${id}`
    )
  },
  /**
     * 撤销审核
     * @param {String} id {id=航次id}
     */
  reqRevokeExamine(id) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/costStorage/revokeByCostId?id=${id}`
    )
  }
}
export default api
